<?php
/**
 * PM5 PHP Framework
 * Originally developed by Patrick McGovern
 * 
 * This is the output handler for standard browsers
 *
 */
class OutputHandler {
	/**
	 * THis is the reference to the main object, giving us access
	 * to all of it's public features, along with the public features
	 * of those classes and files it instantiates
	 *
	 * @var object
	 */
	private $main;
	
	/**
	 * Top HTML block of the output wrapper
	 *
	 * @var string
	 */
	public $headerHTML;
	
	/**
	 * Bottom HTML block of the output wrapper
	 *
	 * @var string
	 */
	public $footerHTML;
	
	/**
	 * The construct runs all of the instantiation instructions
	 * for this class
	 *
	 * @param object $main
	 * @return boolean
	 */
	public function __construct($main)
	{
		$this->main = $main;
		
		/**
		 * Generate the top html block
		 */
		$this->_generateHeaderHTML();
		
		/**
		 * Generate the bottom HTML block
		 */
		$this->_generateFooterHTML();
		
		return true;
	}
	
	private function _generateHeaderHTML()
	{
		$html  = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n";
		$html .= "	\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
		$html .= "<html xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:dcterms=\"http://purl.org/dc/terms/\" xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:review=\"http://www.purl.org/stuff/rev#\" xmlns:sioc=\"http://rdfs.org/sioc/ns#\" xmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\" xmlns:foaf=\"http://xmlns.com/foaf/0.1/\" >\n";
		$html .= "<head>\n";
		$html .= "	<title>{$this->main->pageTitle}</title>\n";
		$html .= "	<meta http-equiv=\"X-UA-Compatible\" content=\"IE=EmulateIE7\" />\n";
		$html .= "	<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n";
		$html .= "	<meta name=\"keywords\" content=\"{$this->main->metaKeywords}\" />\n";
		$html .= "	<meta name=\"description\" content=\"{$this->main->metaDescription}\" />\n";
		$html .= "	<link rel=\"stylesheet\" type=\"text/css\" href=\"css/standardBrowser.css\" media=\"all\" />\n";
		$html .= "	<!--[if lte IE 6]><link rel=\"stylesheet\" type=\"text/css\" href=\"css/standardBrowserIE6.css\" media=\"all\" /><![endif]-->\n";
		$html .= "	<!--[if IE 7]><link rel=\"stylesheet\" type=\"text/css\" href=\"css/standardBrowserIE7.css\" media=\"all\" /><![endif]-->\n";
		$html .= "	<link rel=\"icon\" href=\"/favicon.ico\" type=\"image/x-icon\" />\n";
		$html .= "</head>\n";
		$html .= "<body>\n";
		$html .= "<html>\n";
		$html .= "<div id=\"container\">\n";
		$html .= "	<div id=\"wrapper\">\n";
		$html .= "		<div id=\"header\">\n";
		$html .= "		</div>\n"; // 'header' div
		$html .= "		<div id=\"content\">\n";
		
		
		$this->headerHTML = $html;
		unset($html);
		
		return true;
	}
	
	private function _generateFooterHTML()
	{
		$html  = '';
		$html .= "		</div>\n"; // 'content' div
		$html .= "	</div>\n"; // 'wrapper' div
		$html .= "</div>\n"; // 'container' div
		$html .= "</html>\n";
		
		$this->footerHTML = $html;
		unset($html);
		
		return true;
	}
}